version: '3.8'

services:
  rabbitmq:
    image: rabbitmq:3.13.0-rc.5-management-alpine
    container_name: rabbitmq
    ports: [ "15672:15672" ]

#  redis:
#    image: redis:7-alpine
#    container_name: redis
#    command: ["redis-server", "--appendonly", "no", "--maxmemory", "500mb", "--maxmemory-policy", "allkeys-lru"]
#    ports: [ "6379:6379" ]

  mongo-setup:
    image: mongo:latest
    container_name: mongo-setup
    depends_on: [ mongo1, mongo2, mongo3 ]
    volumes: [ ./rs-init.sh:/scripts/rs-init.sh ]
    entrypoint: [ bash, /scripts/rs-init.sh ]

  eureka-server:
    container_name: eureka-server
    build: ./eureka-server
    ports: [ "8761:8761" ]

  gateway:
    container_name: gateway
    build: ./gateway
    depends_on: [ manager, worker1 ]
    ports: [ "8765:8765" ]

  manager:
    container_name: manager
    build: ./manager
    depends_on: [ rabbitmq, eureka-server ]

  worker1:
    container_name: worker1
    build: ./worker
    depends_on: [ manager ]

  worker2:
    container_name: worker2
    build: ./worker
    depends_on: [ manager ]

  mongo1:
    image: mongo:latest
    container_name: mongo1
    command: [ "--replSet", "my-replica-set", "--bind_ip_all" ]
    ports: [ "27017:27017" ]

  mongo2:
    image: mongo:latest
    container_name: mongo2
    command: [ "--replSet", "my-replica-set", "--bind_ip_all" ]
    ports: [ "27018:27017" ]

  mongo3:
    image: mongo:latest
    container_name: mongo3
    command: [ "--replSet", "my-replica-set", "--bind_ip_all" ]
    ports: [ "27019:27017" ]
